import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import * as dayjs from 'dayjs';
@Entity('page')
export class Page {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;
  @Column()
  prompt: string;
  @Column()
  nameBackground: string;

  @Column()
  nameColor: string;

  @Column({
    nullable: true,
  })
  title: string;

  @Column({
    nullable: true,
  })
  subtitle: string;

  @Column({ default: 0 })
  pv: string;

  @Column({ default: 0 })
  uv: string;

  @Column('simple-json', { nullable: true })
  components: string;

  @Column({ nullable: true })
  shareImg: string;

  @Column('simple-json', { nullable: true })
  shareImgList: string;

  @Column({ nullable: true })
  qrImg: string;

  @Column('simple-json', { nullable: true })
  qrImgList: string;

  @Column({
    default: false,
  })
  getPhone: boolean;

  @Column()
  status: boolean;

  @Column({
    select: false,
    transformer: {
      to: (value) => value,
      from: (value) => dayjs(value).format('YYYY-MM-DD HH:mm:ss'),
    },
  })
  createdAt: Date;

  @Column({
    transformer: {
      to: (value) => value,
      from: (value) => dayjs(value).format('YYYY-MM-DD HH:mm:ss'),
    },
  })
  updatedAt: Date;
}
